package com.ming.sps.server.action;

import java.util.List;
import java.util.Map;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ming.sps.server.bean.ParamMap;
import com.ming.sps.server.utils.JsonUtil;
import com.ming.sps.server.utils.MingUtil;

import net.sf.json.JSONObject;

public class PublicNoticeBaseAction extends BaseAction {

    @RequestMapping("query")
    @ResponseBody
    public String query() throws Exception {
    	int page = Integer.parseInt(getRequest("page", "1"));
        int pagesize = Integer.parseInt(getRequest("pagesize", "10"));
        String ret = "";
        JSONObject jsonObject = new JSONObject();
        Map<String, Object> map = requestParam(getRequest());
        map.remove("page");
        map.remove("pagesize");
        
        System.out.println(map.toString());
        int total = dao.querySizeByPage("select * from t_bussiness_publicnotice",map,true);
        ParamMap p = new ParamMap();
        p.put("total", total);
        List<ParamMap> publicnotice = dao.queryListByPage("select * from t_bussiness_publicnotice",map,"order by jdrq desc",true, page,pagesize);
        jsonObject = JsonUtil.put(jsonObject, "page", p);
        jsonObject = JsonUtil.put(jsonObject, "publicnotice", publicnotice);
        ret = jsonObject.toString();
        return MingUtil.encrypt(ret);
    }

    
}
